// export type MessageMapping = {
//   mapping: {
//     [key: string]: Message;
//   };
//   [key: string]: any;
// };

type BaseMessage = {
  id: string;
  // parent?: string;
  content: string;
  timestamp: number;
};

export type IUserMessage = BaseMessage & {
  role: "user";
};

export type IResponseMessage = BaseMessage & {
  role: "assistant";
  source: { title: string; url: string }[];
  recommend: string[];
  done?: boolean;
  error?: any;
};

// export type Message = IUserMessage | IResponseMessage;

export type Message<
  T extends IUserMessage | IResponseMessage = IUserMessage | IResponseMessage,
> = {
  id: string;
  parent: string | null;
  children: string[];
  message: T;
};
